package cn.psvmc.cxzapi.controller.customer;

import cn.psvmc.cxzapi.model.common.CustomerEntity;
import cn.psvmc.cxzapi.model.common.SearchEntity;
import cn.psvmc.cxzapi.model.customer.TCustomerAuth;
import cn.psvmc.cxzapi.response.Result;
import cn.psvmc.cxzapi.response.ResultGenerator;
import cn.psvmc.cxzapi.service.customer.TCustomerMyService;
import cn.psvmc.cxzapi.util.ToolUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author ywx 个人
 * @className TCustomerMyController
 * @description
 * @date 2024/9/3 22:29
 **/
@RestController
@RequestMapping("/mpapi/customer_my")
public class TCustomerMyController {
    @Resource
    private TCustomerMyService tCustomerMyService;

    /**
     * @Description 登录
     * @Date 2024/8/29 21:43
     * @Author YWX
     * @Param [tCustomer]
     * @Return cn.psvmc.cxzapi.response.Result
     **/
    @PostMapping("/login")
    public Result login(@RequestBody CustomerEntity tCustomer) {
        ToolUtils.validation(new Object[]{tCustomer.getAuthCode(), "授权码", 2});
        return tCustomerMyService.login(tCustomer);
    }

    /**
     * @Description 帮助中心列表
     * @Date 2024/8/29 22:28
     * @Author YWX
     * @Param [entity]
     * @Return cn.psvmc.cxzapi.response.Result
     **/
    @PostMapping("/list_help")
    public Result listHelp(@RequestBody SearchEntity entity) {
        return ResultGenerator.genSuccessResult("查询成功！", tCustomerMyService.listHelp(entity));
    }

    /**
     * @Description 补充用户资料
     * @Date 2025/1/22 23:24
     * @Author YWX
     * @Param [auth]
     * @Return cn.psvmc.cxzapi.response.Result
     **/
    @PostMapping("/update_user_profile")
    public Result updateUserProfile(@RequestBody TCustomerAuth auth) {
        tCustomerMyService.updateUserProfile(auth);
        return ResultGenerator.genSuccessResult("补充资料成功！");
    }

}
